SetControlBarPos 1,1//打包好的小精灵要设置小精灵在最小面,不然会跳死
SetScreenScale 720, 1280, 1//设置这个支持1080.1920分辨率手机,320dpi
Do
KeepCapture
Dim 颜色,颜色1,颜色3,颜色33
颜色 = BGR2HSV(GetPixelColor(50, 390))
颜色3 = GetPixelColor(50, 390)
Dim intX,intY
FindMultiColor 0,0,0,0,"7B4C53","0|-62|3B3534,-18|-42|413736,19|-41|6E4946,0|-24|523F3E,0|-15|3B3434,0|75|663C36,-24|62|492B2B,24|61|503538,-18|0|413736",0,0.95,intX,intY
If intX > -1 And intY > -1 Then
TracePrint intX & "..." & intY
Dim intX1=50
Dim intX2=700
If intX >= 355 Then
intx2 = intX-30
intY = intY + 20
Else
intX1 = intX + 30
intY = intY + 20
End If
Dim 找到=False,物体颜色
For y = (intY - 300) To intY step 4
For x = intX1 To intX2 step 7
物体颜色 = BGR2HSV(GetPixelColor(x, y))
物体颜色 = Split(物体颜色, ".")
颜色1 = Split(颜色, ".")
If (CLng(颜色1(0)) - 14) <= CLng(物体颜色(0)) <= (CLng(颜色1(0)) + 14) And (CLng(颜色1(1)) - 3) <= CLng(物体颜色(1)) <= (CLng(颜色1(1)) + 3) And (CLng(颜色1(2)) - 2) <= CLng(物体颜色(2)) <= (CLng(颜色1(2)) + 2) Then
Else
Dim i=0,ii=0
TracePrint x,y
//////////////计算顶部X左边坐标
For i = 0 To 30
Dim 判断颜色 = BGR2HSV(GetPixelColor(x-i, y))
判断颜色 = Split(判断颜色, ".")
If (CLng(物体颜色(0)) - 14) <= CLng(判断颜色(0)) <= (CLng(物体颜色(0)) + 14) And (CLng(物体颜色(1)) - 3) <= CLng(判断颜色(1)) <= (CLng(物体颜色(1)) + 3) And (CLng(物体颜色(2)) - 2) <= CLng(判断颜色(2)) <= (CLng(物体颜色(2)) + 2) Then
x = x - i
Else
Exit For
End If
Next
//////////////计算顶部X左边坐标
//////////////计算顶部X右边坐标
Dim xx
For i = 0 To 70
判断颜色 = BGR2HSV(GetPixelColor(x + i, y))
判断颜色 = Split(判断颜色, ".")
If (CLng(物体颜色(0)) - 14) <= CLng(判断颜色(0)) <= (CLng(物体颜色(0)) + 14) And (CLng(物体颜色(1)) - 3) <= CLng(判断颜色(1)) <= (CLng(物体颜色(1)) + 3) And (CLng(物体颜色(2)) - 2) <= CLng(判断颜色(2)) <= (CLng(物体颜色(2)) + 2) Then
xx = x + i
End If
Next
TracePrint x & "...." & xx & "X坐标中间点" & x + CLng(((xx - x) / 2))
//////////////计算顶部Y右边坐标
x = x + CLng(((xx - x) / 2))//计算出物体中间的X坐标(),提高准确率.正方圆柱比较精准,方块和个别物体有偏差
TracePrint x,y
// ShowMessage ".", 2000, x - 55, y - 55
Dim 物体X距离
If intX > x Then
物体X距离 = intX - x
Else
物体X距离 = x - intX
End If
找到 = True
Exit For
End If
Next
If 找到 = True Then
TracePrint "物体X距离:"&物体X距离
TouchDown 100, 100, 1
Delay 物体X距离 * 2.4
TouchUp 1
Delay 500
Exit For
End If
Next
End If
ReleaseCapture
Delay 1000
颜色33 = GetPixelColor(50, 390)
If 颜色3 = 颜色33 Then
Else
TracePrint "背景色变了"
Delay 5000
End If
FindPic 0,0,0,0,"Attachment:再来.png","000000",0,0.95,intX,intY
If intX > -1 And intY > -1 Then
Tap intX, intY
Delay 5000
End If
Loop
Function BGR2HSV(bgrvalue)
If len(bgrvalue) < 6 Then
bgrvalue = "000000"
End If
Dim b = left(right(bgrvalue, 6), 2)
Dim g = left(right(bgrvalue, 4), 2)
Dim r = right(bgrvalue, 2)
r = CLng("0x"&r)
g =    CLng("0x"&g)
b = CLng("0x"&b)
Dim max = r
Dim min = r
If max < g Then
max = g
End If
If max < b Then
max = b
End If
If min > g Then
min = g
End If
If min > b Then
min = b
End If
Dim h
If r = max Then
h = (g - b) / (max - min)
End If
If g = max Then
h = 2 + (B - R) / (max - min)
End If
If b = max Then
h = 4 + (R - G) / (max - min)
End If
h = h * 60
If h < 0 Then
h = h + 360
End If
h = Round(h)
Dim s = (max - min) / max
s = s * 100
s = Round(s)
Dim v = (max / 255) * 100
v = Round(v)
BGR2HSV = h & "." & s & "." & v
End Function